<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>js改变背景颜色</title>
</head>
<body>
    
<input type="button" value="红色" onclick="color('red') " >
<input type="button" value="绿色" onclick="color('green')">
<input type="button" value="黄色" onclick="color('yellow')">


<input type="color" onchange="color_diy(this)">
    
    
<script>

    function color(a){
     document.querySelector("body").style.background=a;
}

function color_diy(e){
    color(e.value)
}
    
</script>   
</body>
</html>